/*
 * @(#)EngineRepositoryTest.java $version 2012. 2. 22.
 *
 * Copyright 2012 NHN Corp. All rights Reserved. 
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package com.mywep.myalimi.repository.engine;

import static org.junit.Assert.*;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.mywep.myalimi.model.Engine;
import com.mywep.myalimi.model.Keyword;

import com.nhncorp.lucy.spring.core.util.DataMap;

/**
 * @author 한지웅
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class EngineRepositoryTest {
	@Autowired
	private EngineRepository engineRepository;

	/**
	 * Test method for {@link com.mywep.myalimi.repository.engine.EngineRepository#countByExample(com.nhncorp.lucy.spring.core.util.ExtendedMap)}.
	 */
	@Test
	public void testCountByExample() {
		DataMap param = new DataMap();
		int result = engineRepository.countByExample(param);
		assertTrue(result >= 1);

	}

	/**
	 * Test method for {@link com.mywep.myalimi.repository.engine.EngineRepository#selectByExample(com.nhncorp.lucy.spring.core.util.ExtendedMap)}.
	 */
	@Test
	public void testSelectByExample() {
		DataMap param = new DataMap();
		param.put("engine_type", "NAVER");
		List<Keyword> keywords = engineRepository.selectByExample(param);
		assertEquals(keywords.size(), 1);
		assertEquals(keywords.get(0).getKeyword(), "NAVER");
	}

	/**
	 * Test method for {@link com.mywep.myalimi.repository.engine.EngineRepository#selectByPrimaryKey(E)}.
	 */
	@Test
	public void testSelectByPrimaryKey() {
		Engine param = new Engine();
		param.setEngineType("NAVER");
		List<Keyword> keywords = engineRepository.selectByPrimaryKey(param);
		assertEquals(keywords.size(), 1);
		assertEquals(keywords.get(0).getKeyword(), "NAVER");
	}

}
